<template>
  <!--这个组件专门写顶部导航相关的内容 -->
    <div class="topnav container">
      <!-- 动画图标区域 -->
      <div class="logo">
        <a href="/index"></a>
      </div>
      <!-- 商品菜单区域 -->
      <div class="menu" >
      </div>
      <!-- 搜索框区域 -->
      <div class="search">
        <input type="text" v-model="keyword" placeholder="跨境电商" />
        <span class="search-btn" @click="search"></span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TopNav",
  data () {
    return {
      keyword: ''
    }
  },
  methods: {
    /**
     * 搜索商品
     */
    search () {
      let query = {
        goodsName: this.keyword
      }
      this.$api.shop.getAllGoods(query).then(res => {
        if (res.code === 200) {
          this.$router.push("/detail/" + res.data.records[0].id)
        }
      })
    }
  }
};
</script>
<style scoped>
.topnav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 112px;
  background-color: #fff;
}
/*logo区域  */
.logo {
  width: 65px;
  height: 65px;
  background-color: #ff6600;
  overflow: hidden;
}
.logo a {
  display: inline-block;
  width: 130px;
  height: 65px;
}
.logo a::before {
  content: "";
  display: inline-block;
  width: 65px;
  height: 65px;
  background: url("/imgs/mall-logo.jpg") no-repeat;
  background-size: 65px;
  transition: all 0.5s;
}
.logo a::after {
  content: "";
  display: inline-block;
  width: 65px;
  height: 65px;
  background: url("/imgs/mall-logo.jpg") no-repeat;
  background-size: 65px;
}
.logo a:hover::before {
  margin-left: -65px;
  transition: all 0.5s;
}

/* 中间产品导航区域 */
.menu {
  display: flex;
  margin-left: -164px;
}
.item-menu .title {
  display: inline-block;
  height: 112px;
  line-height: 112px;
  color: #333333;
  font-weight: 600;
  font-size: 16px;
  margin-right: 21px;
  cursor: pointer;
}
.item-menu:hover .title {
  color: #ff6600;
}
.item-menu:hover .children {
  opacity: 1;
  height: 220px;
}

.item-menu .children {
  position: absolute;
  top: 112px;
  left: 0;
  width: 1226px;
  height: 0px;
  opacity: 0;
  overflow: hidden;
  background-color: #fff;
  border-top: 2px solid rgba(0, 0, 0, 0.11);
  box-shadow: 0 7px 6px rgba(0, 0, 0, 0.11);
  transition: all 0.6s;
  z-index: 99;
}
.children .wrapper {
  display: flex;
}
.wrapper .product {
  flex: 1;
  height: 220px;
  position: relative;
}
.wrapper .product::before {
  content: "";
  position: absolute;
  top: 28px;
  right: 0;
  width: 2px;
  height: 99px;
  background-color: rgba(0, 0, 0, 0.11);
}
.wrapper .product:last-child::before {
  background-color: #fff;
}
.product > a {
  display: block;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.product .pro-image {
  width: 100%;
  height: 110px;
  margin-top: 26px;
  text-align: center;
  overflow: hidden;
}
.product .pro-image img {
  height: 110px;
}
.product .pro-name {
  margin: 19px 0 8px 0;
  color: #333333;
}
.product .pro-price {
  color: #ff6600;
  font-weight: 600;
}

/* 右侧搜索框及搜索按钮 */
.search {
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  width: 318px;
  height: 50px;
  border: 1px solid #eee;
}
.search input {
  box-sizing: border-box;
  width: 264px;
  height: 50px;
  line-height: 50px;
  text-indent: 12px;
  border: none;
  border-right: 1px solid #eee;
}
.search .search-btn {
  position: absolute;
  width: 18px;
  height: 18px;
  background: url("/imgs/icon-search.png") no-repeat center;
  background-size: contain;
  top: 16px;
  right: 19px;
  cursor: pointer;
}
</style>


